<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="format-detection" content="telephone=no">
  <meta http-equiv="x-rim-auto-match" content="none">
  <title>支付收银台</title>
  <script src="${request.contextPath}/statics/js/jquery.js"></script>
  <script src="${request.contextPath}/statics/js/qrcode.min.js"></script>
  <style>
    * {
      padding: 0;
      margin: 0;
    }
    a {
      text-decoration: none;
    }

    .clearfix1:after {
      content: '';
      height: 0;
      line-height: 0;
      visibility: hidden;
      display: block;
      clear: both;
    }

    .clearfix1 {
      zoom: 1;
    }

    html, body {
      background-color: #EDEDED;
    }

    .page {
      width: 660px;
      margin: 0 auto 24px;
      background-color: #ffffff;
    }

    .header {
      position: relative;
      text-align: center;
      height: 67px;
      line-height: 67px;
      vertical-align: middle;
      overflow: hidden;
      padding: 10px 0;
    }
 .header .img {
   width: 26%;
   display: inline-block;
 }
    .header img {
      width: 100%;
      vertical-align: middle;
    }

    .main {
      overflow: hidden;
    }

    .main .money {
      margin: 36px auto;
      height: 21px;
      line-height: 21px;
      color: #ff0000;
      font-size: 30px;
      font-family: HelveticaNeue;
      text-align: center;
    }

    .main .qr {
      position: relative;
      width: 250px;
      height: 250px;
      margin: 0 auto;
      background: url("${request.contextPath}/statics/image/box.png") no-repeat;
      background-size: 100% 100%;
      border: 1px solid transparent;
    }
.main .qr .ok {
  display: none;
  position: absolute;
  top: 26px;
  left: 26px;
  width: 200px;
  height: 200px;
  background: url("${request.contextPath}/statics/image/ok.png") no-repeat;
  background-size:100% 100%;

}
    .main .qr #showqr {
	  width: 200px;
      height: 200px;
      margin: 26px auto;
      /*background: url("images/qr.png") no-repeat;*/
      background-size: 100% 100%;
    }

    .main .qr .time {
      width: 176px;
      height: 28px;
      font-size: 22px;
      font-family: PingFangSC-Regular;
      position: absolute;
      top: -12px;
      left: 50%;
      transform: translateX(-50%);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .main .qr .txt {
      color: #999999;
      font-size: 14px;
      width: 150px;
      position: absolute;
      bottom: -6px;
      left: 50%;
      transform: translateX(-50%);
      display: flex;
      align-items: center;
      justify-content: center;
      text-align: center;
    }

    .green {
      color: #4EA5E9;
    }
.save {
  display: none;
}
    .main .order {
      margin: 21px auto 14px;
      text-align: center;
      font-size: 18px;
      color: #999999;
      font-family: PingFangSC-Medium;
    }

    .main .txt1,.main .txt2 {
      letter-spacing: 1px;
      width: 60%;
      padding: 2% 0;
      text-align: center;
      margin: 0 auto 20px;
      color: #ffffff;
      font-size: 22px;
      /*font-weight: bold;*/
      font-family: PingFangSC-Regular;
      background: #4EA5E9;
      border-radius: 5px;
    }

    .main .footer {
      width: 80%;
      margin: 27px auto 0;
      border-top: 2px solid #dbdbdb;
      padding-top: 12px;
      font-size: 20px;
      color: #000;
    }
    .main .footer div {
      padding-left: 20px;
    }
    .main .footer .tip {
      float: left;
      display: inline-block;
      width: 20px;
      height: 20px;
      background: url("${request.contextPath}/statics/image/tip.png") no-repeat;
      background-size: 100% 100%;
    }

    .tip_txt {
      float: left;
      font-size: 20px;
      margin-left: 8px;
      color: #ff0000;
      display: inline-block;
      height: 18px;
      line-height: 18px;
    }

    .main .footer p {
      margin-bottom: 6px;
      padding-left: 20px;
      padding-bottom: 12px;
      border-bottom: 1px dotted #f1f1f1;
    }
    .mob {
      display: none;
    }
    @media (max-width: 640px) {
      @keyframes changeColor {
        0%{color: #d82b1e}
        50% {color: #e79739;}
        100%{color: #d82b1e}
      }

      .page {
        width: 100%;
        margin: auto;
        background-color: #EDEDED;
      }
      .header {
        height: 50px;
        line-height: 50px;
        margin-top: 100px;
            margin-bottom: 15px;
        padding: 0;
      }
      .header .img {
        width: 30%;
      }
      .main .money {
        margin: 15px auto 35px;
      }
      .main .qr .time {
        font-size: 20px;
      }
      .main .order {
        font-size: 15px;
      }
      .main .order .save {
        display: block;
        font-weight: bold;
        font-size: 18px;
        color: #333333;
        margin-bottom: 10px;
      }
      .mob {
        display: block;
      }
      .main .txt1,.main .txt2 {
        width: 85%;
        padding: 3% 0;
        font-size: 18px;
        margin: 0 auto 10px;
        font-weight: bold;
        background-color: #4EA5E9;
      }
      .main .footer {
        margin: 15px auto 0;
        font-size: 15px;
        width: 95%;
      }
      .main .footer div {
        padding-left: 15px;
      }
      .main .footer p {
        margin-bottom: 3px;
        padding-left: 15px;
        padding-bottom: 5px;
      }
      .main .footer .tip {
        width: 18px;
        height: 18px;
      }
      .tip_txt {
        font-size: 18px;
      }
    }
  </style>
</head>
<body>
<div class="header page">
  <span class="img">
      <img src="${request.contextPath}/statics/image/logo.png" alt="">
  </span>
</div>
<div class="main page">
  <div class="qr clearfix1">
    <div class="ok"></div>
    	<img id="showqr" src="${request.contextPath}/statics/image/loading.gif" alt=""  style="width: 200px; position: absolute;left: 25px;" >
  </div>
  <div class="order"><span class="save">订单号：${orderid !''}</span></div>
  
  <div class="txt1" onclick="pay();">
    <span class="mob">正在请求支付。。。</span>
  </div>
  <div class="txt2" onclick="goBackHome();" style="display: none;">
    <span class="mob">点击返回首页</span>
  </div>
</div>
</body>

<script src="https://cdn.bootcss.com/layer/2.3/layer.js"></script>
<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.inc.min.js"></script>
<script type="text/javascript">
var orderid = "${orderid !''}"; //订单号
var payaliuserid = "${payaliuserid !''}"; //付款人userid
var qrcodestr;
pay();
function pay(){
    $.ajax({
      type: 'GET',
      url: '${request.contextPath}/api/zfb_initiative_tobilldetails/'+orderid+'?payaliuserid='+payaliuserid,
      dataType: 'json',
      success: function (str) {
        if (str.code == 0) {
        	 $("#showqr").attr("src","${request.contextPath}/statics/image/ready.png");
        	 $('.txt1').hide();
        	 $('.txt2').show();
        	 /* qrcodestr=str.orderStr;
        	 goAliPay();//唤起支付 */
        	 AlipayJSBridge.call('pushWindow', { url: str.billdetailurl });
        }else{
        	alert(str.msg);
        	$("#showqr").attr("src","${request.contextPath}/statics/image/pay_error.png");
	    	$('.txt1 span').text('请点击重新唤起支付请求');
        }
      }
    });
  }
</script>
<script type="text/javascript">
function goAliPay() {
	var orderStr = (qrcodestr);
	ap.tradePay({
	      orderStr:orderStr
	  }, function(result){
	      if(result.resultCode==9000||result.resultCode=="9000"){
	    	  $("#showqr").attr("src","${request.contextPath}/statics/image/pay_ok.png");
	    	  $('.txt1 span').text('已完成支付，请返回首页');
	    	  setTimeout(goBackHome,3000);
	      }else{
	    	  $("#showqr").attr("src","${request.contextPath}/statics/image/pay_error.png");
		      $('.txt1 span').text('充值失败请重新生成二维码');
	      }
	  });
   }
</script>

<script>
	function goBackHome(callback) {
		AlipayJSBridge.call('popWindow');
		if (window.AlipayJSBridge) {
			callback && callback();
		} else {
			document.addEventListener('AlipayJSBridgeReady', callback, false);
		}
	}
</script>
</html>